<?php
/*
*产品新增
*/
namespace Admin\Func;

class Func902020101 {
    var  $db;
    var $rst;
    var $errmsg;
    var  $ProductCode;
    var  $ProductName;
    var  $BasePrice;
    var  $ProductCategoryId;
    var  $BrandID;
    var  $ProductIMG;
    var  $ProductSIMG;
    var  $ProductStatus;

    public function __construct($ProductCode,$ProductName,$BasePrice,$ProductCategoryId,$BrandID,$ProductIMG,$ProductSIMG,$ProductStatus) {
        $this->db  = new \Think\Model();
        $this->errmsg = '';
        $this->ProductCode = addslashes($ProductCode);
        $this->ProductName = addslashes($ProductName);
        $this->BasePrice = addslashes($BasePrice);
        $this->ProductCategoryId = addslashes($ProductCategoryId);
        $this->BrandID = addslashes($BrandID);
        $this->ProductIMG = addslashes($ProductIMG);
        $this->ProductSIMG = addslashes($ProductSIMG);
        $this->ProductStatus = addslashes($ProductStatus);

    }
    /*
    *获取错误信息
    */
    public function getErrMsg() {
        return $this->errmsg;
    }
    /*
    *验证
    */
    private function validate(){
        return true;
    }
    /*
    *执行
    */
    public function execute(){
        $vflag = true;
        $OperID = I('OperID');
        if($this->validate()){

            $sql = <<<EOD
INSERT INTO t_lz_ps_product(
ProductCode,
ProductName,
BasePrice,
ProductCategoryId,
BrandID,
ProductIMG,
ProductSIMG,
ProductStatus,

        OperID,
        OperDate
        )values(
        '$this->ProductCode',
        '$this->ProductName',
        '$this->BasePrice',
        '$this->ProductCategoryId',
        '$this->BrandID',
        '$this->ProductIMG',
        '$this->ProductSIMG',
        '$this->ProductStatus',

        '$OperID',
        now()
)

EOD;

            //$this->rst = $this->db->query($sql);
            $this->rst = $this->db->execute($sql);
            if ($this->rst === false){
                $this->errmsg = $this->db->getDbError();
                $vflag = false;
            }else{
                $vflag = true;  
            }
        }else{
            $vflag = false;
        }
    return  $vflag;
    }
    public function getRst(){
        return $this->rst;
    }
}
